using System;
using System.Collections.Specialized;
using System.Xml;
using System.Collections.Generic;

namespace FreeFlow.Client
{
  /// <summary>Radio group orientation.</summary>
  public enum Orientation
  {
    /// <summary>Vertical orientation.</summary>
    Vertical,
    /// <summary>Horizontal orientation.</summary>
    Horizontal
  }

	/// <summary>A radio group field.</summary>
	[Serializable]
	public class RadioGroupField : Field
	{
    internal RadioGroupField(Form form, XmlElement fieldNode)
      : base(form, fieldNode)
    {
      FillFromOptionList(options, fieldNode);
      if (fieldNode.GetAttribute("Orientation") == "Horizontal")
        orientation = Orientation.Horizontal;
      else
        orientation = Orientation.Vertical;
      caption = fieldNode.GetAttribute("Caption");
    }

    #region properties
    
    private string caption;
    /// <summary>
    /// Gets the caption of the radiogroup.
    /// </summary>
    public string Caption
    {
      get
      {
        return caption;
      }
    }

    private Orientation orientation;
    /// <summary>
    /// Gets the orientation of the radio group.
    /// </summary>
    public Orientation Orientation
    {
      get { return orientation; }
    }

    #endregion
    #region options
    private List<string> options = new List<string>();
    /// <summary>
    /// Gets the number of options in the radiogroup.
    /// </summary>
    public int OptionCount
    {
      get
      {
        return options.Count;
      }
    }

    /// <summary>
    /// Gets the option at the specified index.
    /// </summary>
    /// <param name="index">Index.</param>
    /// <returns></returns>
    public string Option(int index)
    {
      return options[index];
    }
    #endregion
	}
}
